﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MongoDB.Driver;
using PICOC.AspNet.View.Model;
using System.Text;
using System.Configuration;

namespace PICOC.AspNet.View
{
    public partial class About : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String connectionstring = "mongodb://appharbor_486d956f-0594-43c5-8c48-4dbe75a2626d:pmcqd2l35plcg201m16j9rno1v@ds031747.mongolab.com:31747/appharbor_486d956f-0594-43c5-8c48-4dbe75a2626d";
            var database = MongoDatabase.Create(connectionstring);
            var collection = database.GetCollection<Log>("Logs");
            
            var logs = collection.FindAll();

            StringBuilder builder = new StringBuilder();
            builder.AppendLine(logs.Count().ToString());

            foreach (var log in logs.OrderByDescending(x => x.Access).Take(20))
            {
                builder.AppendLine(log.Access.ToString());
            }
            
            tbLog.Text = builder.ToString();
        }
    }
}
